package com.aistar.mapper;

import com.aistar.model.entity.Intern;
import com.aistar.model.entity.RecruitmentLabel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: RecruitmentLabelMapper
 * @author: LiuWenXiu
 * @date: 2021/9/30 22:22
 * @Description: TODO...
 */
public interface RecruitmentLabelMapper {
    //通过职位id查找标签
    @Select("select * from recruitment_label where recruitment_id=#{id}")
    List<RecruitmentLabel> FindRecruitment(Integer id);

    //查找全部标签
    @Select("select * from recruitment_label")
    List<RecruitmentLabel> findAll();

    //通过职位id查找标签id
    @Select("select tag_id from recruitment_label where recruitment_id=#{id}")
    List<Integer> findTagId(Integer id);

    // 根据职位id和标签id插入职位标签数据
    @Insert("insert into recruitment_label(recruitment_id,tag_id) values(#{recruitmentId},#{tagId})")
    Integer insertRecruitmentLabel(RecruitmentLabel recruitmentLabel);

    // 根据职位id删除记录
    @Delete("delete from recruitment_label where  recruitment_id = #{id}")
    Integer deleteByRecruitment(Integer id);

    // 根据职位id和标签id删除记录
    @Delete("delete from recruitment_label where recruitment_id = #{recruitmentId} and tag_id = #{tagId}")
    Integer deleteBy(@Param("recruitmentId") Integer recruitmentId, @Param("tagId") Integer tagId);

    //通过标签id获取职位id
    @Select("select recruitment_id from recruitment_label where tag_id=#{id}")
    List<Integer> findByTagId(Integer id);
}
